let StatusUtils = require("./StatusUtils");

class ResponseUtils {
    constructor(data) {
        //this.status = data.status;
        //this.code = data.code;
        //this.msg = data.msg;
        this.data = data;
    }

    static builder(data) {
        return new ResponseUtils(data);
    }

    build() {
        return this;
    }

    setData(data) {
        this.data = data;
        return this;
    }

    getData() {
        return this.data;
    }

    setCode(code) {
        this.code = code;
        return this;
    }

    getCode() {
        return this.code;
    }

    setStatus(status) {
        this.status = status;
        return this;
    }

    getStatus() {
        return this.status;
    }

    setMsg(msg) {
        this.msg = msg;
        return this;
    }

    getMsg() {
        return this.msg;
    }

    success() {
        this.code = StatusUtils.status.get(StatusUtils.SUCCESS).code;
        this.msg = StatusUtils.status.get(StatusUtils.SUCCESS).msg;
        return this;
    }

    failer() {
        this.code = StatusUtils.status.get(StatusUtils.ERROR).code;
        this.msg = StatusUtils.status.get(StatusUtils.ERROR).msg;
        return this;
    }
}

module.exports = ResponseUtils;